package com.xsdl.flyweight.txt;

import java.util.List;

public  class FontFactory {

    private FontFactory() {

    }

    private static class FontFactoryHolder {
        private static final FontFactory INSTANCE = new FontFactory();
    }

    public static FontFactory getInstance() {
        return FontFactoryHolder.INSTANCE;
    }

    private static final List<Font> fontList = List.of(
            new Font("Arial", 12),
            new Font("Arial", 14),
            new Font("Arial", 16)
    );

    public Font getFont(String type, int size) {
        for (Font font : fontList) {
            if (font.getType().equals(type) && font.getSize() == size) {
                return font;
            }
        }
        return new Font(type, size);
    }

}
